package tn.softcom.dfbuilder.modele;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import tn.softcom.dfbuilder.Utils;

public class ADJGCells implements Cloneable {
	private String source;
	private String destination;
	private String Parameter;
	private String PLMN = "PLMN";
	private String RNC;
	private String WBTS;
	private String LcrId;
	private String ADJGId;
	private String AdjgMCC;
	private String AdjgMNC;
	private String ADJGChangeOrigin;
	private String ADJGType;
	private String AdjgBCC;
	private String AdjgBCCH;
	private String AdjgBandIndicator;
	private String AdjgCI;
	private String AdjgLAC;
	private String AdjgNCC;
	private String AdjgSIB;
	private String AdjgTxPwrMaxRACH;
	private String AdjgTxPwrMaxTCH;
	private String NrtHopgIdentifier;
	private String RtHopgIdentifier;
	
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	public String getDestination() {
		return destination;
	}
	public void setDestination(String destination) {
		this.destination = destination;
	}
	public String getParameter() {
		return Parameter;
	}
	public void setParameter(String parameter) {
		Parameter = parameter;
	}
	public String getPLMN() {
		return PLMN;
	}
	public void setPLMN(String pLMN) {
		PLMN = pLMN;
	}
	public String getRNC() {
		return RNC;
	}
	public void setRNC(String rNC) {
		RNC = rNC;
	}
	public String getWBTS() {
		return WBTS;
	}
	public void setWBTS(String wBTS) {
		WBTS = wBTS;
	}
	public String getLcrId() {
		return LcrId;
	}
	public void setLcrId(String LcrId) {
		this.LcrId = LcrId;
	}
	public String getADJGId() {
		return ADJGId;
	}
	public void setADJGId(String aDJG) {
		ADJGId = aDJG;
	}
	public String getAdjgMCC() {
		return AdjgMCC;
	}
	public void setAdjgMCC(String adjgMCC) {
		AdjgMCC = adjgMCC;
	}
	public String getAdjgMNC() {
		return AdjgMNC;
	}
	public void setAdjgMNC(String adjgMNC) {
		AdjgMNC = adjgMNC;
	}
	public String getADJGChangeOrigin() {
		return ADJGChangeOrigin;
	}
	public void setADJGChangeOrigin(String aDJGChangeOrigin) {
		ADJGChangeOrigin = aDJGChangeOrigin;
	}
	public String getADJGType() {
		return ADJGType;
	}
	public void setADJGType(String aDJGType) {
		ADJGType = aDJGType;
	}
	public String getAdjgBCC() {
		return AdjgBCC;
	}
	public void setAdjgBCC(String adjgBCC) {
		AdjgBCC = adjgBCC;
	}
	public String getAdjgBCCH() {
		return AdjgBCCH;
	}
	public void setAdjgBCCH(String adjgBCCH) {
		AdjgBCCH = adjgBCCH;
	}
	public String getAdjgBandIndicator() {
		return AdjgBandIndicator;
	}
	public void setAdjgBandIndicator(String adjgBandIndicator) {
		AdjgBandIndicator = adjgBandIndicator;
	}
	public String getAdjgCI() {
		return AdjgCI;
	}
	public void setAdjgCI(String adjgCI) {
		AdjgCI = adjgCI;
	}
	public String getAdjgLAC() {
		return AdjgLAC;
	}
	public void setAdjgLAC(String adjgLAC) {
		AdjgLAC = adjgLAC;
	}
	public String getAdjgNCC() {
		return AdjgNCC;
	}
	public void setAdjgNCC(String adjgNCC) {
		AdjgNCC = adjgNCC;
	}
	public String getAdjgSIB() {
		return AdjgSIB;
	}
	public void setAdjgSIB(String adjgSIB) {
		AdjgSIB = adjgSIB;
	}
	public String getAdjgTxPwrMaxRACH() {
		return AdjgTxPwrMaxRACH;
	}
	public void setAdjgTxPwrMaxRACH(String adjgTxPwrMaxRACH) {
		AdjgTxPwrMaxRACH = adjgTxPwrMaxRACH;
	}
	public String getAdjgTxPwrMaxTCH() {
		return AdjgTxPwrMaxTCH;
	}
	public void setAdjgTxPwrMaxTCH(String adjgTxPwrMaxTCH) {
		AdjgTxPwrMaxTCH = adjgTxPwrMaxTCH;
	}
	public String getNrtHopgIdentifier() {
		return NrtHopgIdentifier;
	}
	public void setNrtHopgIdentifier(String nrtHopgIdentifier) {
		NrtHopgIdentifier = nrtHopgIdentifier;
	}
	public String getRtHopgIdentifier() {
		return RtHopgIdentifier;
	}
	public void setRtHopgIdentifier(String rtHopgIdentifier) {
		RtHopgIdentifier = rtHopgIdentifier;
	}
	public ADJGCells(String source, String destination) {
		super();
		this.source = source;
		this.destination = destination;
	}
	public ADJGCells() {
		
	}
	
	public Object clone() {
    	Object o = null;
    	try {
      		o = super.clone();
    	} catch(CloneNotSupportedException cnse) {
      		cnse.printStackTrace(System.err);
	    }
	    return o;
  	}
	
	 public void findWCELDataBySourceName() {
			try {
				Connection conn = Utils.getConnection();
				Statement s = conn.createStatement();
				String query = "";
				if("6".equals(source.substring(3, 4)) || "4".equals(source.substring(3, 4))){
					query = "SELECT RncId,WBTSId,LcrId FROM A_WCEL where CellAdditionalInfo = '"+ source.substring(0,3)+"6"+source.substring(4)+"' or CellAdditionalInfo = '"+ source.substring(0,3)+"4"+source.substring(4)+"'";
				}else{
					 query = "SELECT RncId,WBTSId,LcrId FROM A_WCEL where CellAdditionalInfo = '"+source+"'";
				}
				s.execute(query);
				ResultSet rs = s.getResultSet();
				if ((rs != null) && (rs.next())) {
					RNC = (rs.getString("RncId"));
					WBTS = rs.getString("WBTSId");
					LcrId = rs.getString("LcrId");
				}
				rs.close();
				s.close();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
	 
	 
	 public void findADJGDataByDestName() {
			try {
				Connection conn = Utils.getConnection();
				String query = "SELECT A_BTS.segmentName, A_BTS.bsIdentityCodeNCC, A_BTS.bsIdentityCodeBCC, A_BTS.locationAreaIdLAC, A_BTS.cellId, A_TRX.initialFrequency, A_TRX.channel0Type, A_BTS.frequencyBandInUse FROM A_BTS INNER JOIN A_TRX ON (A_BTS.BSCId = A_TRX.BSCId) AND (A_BTS.BCFId = A_TRX.BCFId) AND (A_BTS.BTSId = A_TRX.BTSId) WHERE A_TRX.channel0Type=4 and A_BTS.segmentName = '"+destination+"'";
				Statement s = conn.createStatement();
				s.execute(query);
				ResultSet rs = s.getResultSet();
				if ((rs != null) && (rs.next())) { 
					AdjgNCC = (rs.getString("bsIdentityCodeNCC"));
					AdjgBCC = rs.getString("bsIdentityCodeBCC");
					AdjgLAC = rs.getString("locationAreaIdLAC");
					AdjgCI = (rs.getString("cellId"));
				}
				s.close();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}

}
